package com.lushuan.ch10_springboot_security.mapper;

import com.lushuan.ch10_springboot_security.entity.User;
import com.lushuan.ch10_springboot_security.entity.UserDTO;

public class UserMapper {
    public static UserDTO toUserDTO(User user) {
        if (user == null) {
            return null;
        }
        UserDTO userDTO = new UserDTO();
        userDTO.setId(user.getId());
        userDTO.setUsername(user.getUsername());
        userDTO.setEmail(user.getEmail());
        return userDTO;
    }
}
